<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Reranker Framework (ReFr): candidate.H Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Reranker Framework (ReFr)
   
   </div>
   <div id="projectbrief">Reranking framework for structure prediction and discriminative language modeling</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">candidate.H</div>  </div>
</div><!--header-->
<div class="contents">
<a href="candidate_8_h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright 2012, Google Inc.</span>
<a name="l00002"></a>00002 <span class="comment">// All rights reserved.</span>
<a name="l00003"></a>00003 <span class="comment">// </span>
<a name="l00004"></a>00004 <span class="comment">// Redistribution and use in source and binary forms, with or without</span>
<a name="l00005"></a>00005 <span class="comment">// modification, are permitted provided that the following conditions are</span>
<a name="l00006"></a>00006 <span class="comment">// met:</span>
<a name="l00007"></a>00007 <span class="comment">// </span>
<a name="l00008"></a>00008 <span class="comment">//   * Redistributions of source code must retain the above copyright</span>
<a name="l00009"></a>00009 <span class="comment">//     notice, this list of conditions and the following disclaimer.</span>
<a name="l00010"></a>00010 <span class="comment">//   * Redistributions in binary form must reproduce the above</span>
<a name="l00011"></a>00011 <span class="comment">//     copyright notice, this list of conditions and the following disclaimer</span>
<a name="l00012"></a>00012 <span class="comment">//     in the documentation and/or other materials provided with the</span>
<a name="l00013"></a>00013 <span class="comment">//     distribution.</span>
<a name="l00014"></a>00014 <span class="comment">//   * Neither the name of Google Inc. nor the names of its</span>
<a name="l00015"></a>00015 <span class="comment">//     contributors may be used to endorse or promote products derived from</span>
<a name="l00016"></a>00016 <span class="comment">//     this software without specific prior written permission.</span>
<a name="l00017"></a>00017 <span class="comment">//</span>
<a name="l00018"></a>00018 <span class="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span>
<a name="l00019"></a>00019 <span class="comment">// &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span>
<a name="l00020"></a>00020 <span class="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span>
<a name="l00021"></a>00021 <span class="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span>
<a name="l00022"></a>00022 <span class="comment">// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span>
<a name="l00023"></a>00023 <span class="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span>
<a name="l00024"></a>00024 <span class="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,           </span>
<a name="l00025"></a>00025 <span class="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY           </span>
<a name="l00026"></a>00026 <span class="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span>
<a name="l00027"></a>00027 <span class="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span>
<a name="l00028"></a>00028 <span class="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00029"></a>00029 <span class="comment">// -----------------------------------------------------------------------------</span>
<a name="l00030"></a>00030 <span class="comment">//</span>
<a name="l00031"></a>00031 <span class="comment">//</span>
<a name="l00036"></a>00036 <span class="comment"></span>
<a name="l00037"></a>00037 <span class="preprocessor">#ifndef RERANKER_CANDIDATE_H_</span>
<a name="l00038"></a>00038 <span class="preprocessor"></span><span class="preprocessor">#define RERANKER_CANDIDATE_H_</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include &lt;sstream&gt;</span>
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 <span class="preprocessor">#include &quot;../proto/data.pb.h&quot;</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include &quot;<a class="code" href="factory_8_h.html" title="Provides a generic dynamic object factory.">factory.H</a>&quot;</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include &quot;<a class="code" href="feature-vector_8_h.html" title="Defines the reranker::FeatureVector class, which, as it happens, is used to store feature vectors...">feature-vector.H</a>&quot;</span>
<a name="l00047"></a>00047 <span class="preprocessor">#include &quot;<a class="code" href="symbol-table_8_h.html" title="Provides the reranker::Symbols interface as well as the reranker::StaticSymbolTable implementation...">symbol-table.H</a>&quot;</span>
<a name="l00048"></a>00048 
<a name="l00049"></a>00049 <span class="keyword">namespace </span>reranker {
<a name="l00050"></a>00050 
<a name="l00051"></a>00051 <span class="keyword">using</span> std::ostream;
<a name="l00052"></a>00052 <span class="keyword">using</span> std::string;
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 <span class="keyword">class </span>Model;
<a name="l00055"></a>00055 
<a name="l00060"></a><a class="code" href="classreranker_1_1_candidate.html">00060</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_candidate.html" title="A class to represent a candidate in a set of candidates that constitutes a training instance for a re...">Candidate</a> {
<a name="l00061"></a>00061  <span class="keyword">public</span>:
<a name="l00062"></a><a class="code" href="classreranker_1_1_candidate.html#aef7fb63c41120b60cdde365350a37ce5">00062</a>   <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classreranker_1_1_feature_extractor.html" title="An abstract base class/interface for all feature extractors.">FeatureExtractor</a>;
<a name="l00063"></a><a class="code" href="classreranker_1_1_candidate.html#a859ab638260cebff3ff246e58ea25638">00063</a>   <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classreranker_1_1_abstract_file_backed_feature_extractor.html" title="This class makes it easy for concrete subclasses to extract features based on input from a file...">AbstractFileBackedFeatureExtractor</a>;
<a name="l00071"></a><a class="code" href="classreranker_1_1_candidate.html#aab21e5d206a804f6a6d113e2623644d5">00071</a>   <a class="code" href="classreranker_1_1_candidate.html#aab21e5d206a804f6a6d113e2623644d5" title="Constructor for a candidate without features.">Candidate</a>(<span class="keywordtype">int</span> <a class="code" href="classreranker_1_1_candidate.html#a614992f57ceed690dee107b1e4c40696" title="Returns the index of this candidate relative to the other candidates.">index</a>,
<a name="l00072"></a>00072             <span class="keywordtype">double</span> <a class="code" href="classreranker_1_1_candidate.html#a024f88c11b795a31cb8f5d1b47150701" title="Returns the loss of this candidate.">loss</a>,
<a name="l00073"></a>00073             <span class="keywordtype">double</span> <a class="code" href="classreranker_1_1_candidate.html#a008fd660d5f9687efabb3fe839c19b79" title="Returns the baseline model score for this candidate.">baseline_score</a>,
<a name="l00074"></a>00074             <span class="keywordtype">int</span> <a class="code" href="classreranker_1_1_candidate.html#a240be5b1ef5ac9287128cfa4faf373f2" title="Returns the number of words in this candidate.">num_words</a>,
<a name="l00075"></a>00075             <span class="keyword">const</span> <span class="keywordtype">string</span> &amp;<a class="code" href="classreranker_1_1_candidate.html#abb17414a33453509e2b7cfaf8be02baa" title="Returns the raw data (typically the sentence) for this candidate.">raw_data</a>) :
<a name="l00076"></a>00076       index_(index), num_errors_(0), num_correct_(0),
<a name="l00077"></a>00077       loss_(loss), score_(0.0), baseline_score_(baseline_score),
<a name="l00078"></a>00078       num_words_(num_words), raw_data_(raw_data), compiled_(false) {
<a name="l00079"></a>00079   }
<a name="l00080"></a>00080 
<a name="l00090"></a><a class="code" href="classreranker_1_1_candidate.html#a9ae95cf5d2082b02ae8f1857d50ec29b">00090</a>   <a class="code" href="classreranker_1_1_candidate.html#aab21e5d206a804f6a6d113e2623644d5" title="Constructor for a candidate without features.">Candidate</a>(<span class="keywordtype">int</span> <a class="code" href="classreranker_1_1_candidate.html#a614992f57ceed690dee107b1e4c40696" title="Returns the index of this candidate relative to the other candidates.">index</a>,
<a name="l00091"></a>00091             <span class="keywordtype">double</span> <a class="code" href="classreranker_1_1_candidate.html#a024f88c11b795a31cb8f5d1b47150701" title="Returns the loss of this candidate.">loss</a>,
<a name="l00092"></a>00092             <span class="keywordtype">double</span> <a class="code" href="classreranker_1_1_candidate.html#a008fd660d5f9687efabb3fe839c19b79" title="Returns the baseline model score for this candidate.">baseline_score</a>,
<a name="l00093"></a>00093             <span class="keywordtype">int</span> <a class="code" href="classreranker_1_1_candidate.html#a240be5b1ef5ac9287128cfa4faf373f2" title="Returns the number of words in this candidate.">num_words</a>,
<a name="l00094"></a>00094             <span class="keyword">const</span> <span class="keywordtype">string</span> &amp;<a class="code" href="classreranker_1_1_candidate.html#abb17414a33453509e2b7cfaf8be02baa" title="Returns the raw data (typically the sentence) for this candidate.">raw_data</a>,
<a name="l00095"></a>00095             <span class="keyword">const</span> <a class="code" href="classreranker_1_1_feature_vector.html">FeatureVector&lt;int,double&gt;</a> &amp;<a class="code" href="classreranker_1_1_candidate.html#a741433c66a4cc4dfbb1e4b89c9c6e431" title="Returns the feature vector for this candidate.">features</a>,
<a name="l00096"></a>00096             <span class="keyword">const</span> <a class="code" href="classreranker_1_1_feature_vector.html">FeatureVector&lt;string,double&gt;</a> &amp;<a class="code" href="classreranker_1_1_candidate.html#ab49bd7b1459dcff7c450e5b504204fd5" title="Returns the symbolic feature vector for this candidate.">symbolic_features</a>) : 
<a name="l00097"></a>00097       index_(index), num_errors_(0), num_correct_(0),
<a name="l00098"></a>00098       loss_(loss), score_(0.0), baseline_score_(baseline_score),
<a name="l00099"></a>00099       num_words_(num_words), features_(features),
<a name="l00100"></a>00100       symbolic_features_(symbolic_features), raw_data_(raw_data),
<a name="l00101"></a>00101       compiled_(false) {
<a name="l00102"></a>00102   }
<a name="l00103"></a>00103 
<a name="l00105"></a><a class="code" href="classreranker_1_1_candidate.html#a1be5c468c271f2a0d987f86a9eccfcaa">00105</a>   <span class="keyword">virtual</span> <a class="code" href="classreranker_1_1_candidate.html#a1be5c468c271f2a0d987f86a9eccfcaa" title="Destroys this candidate.">~Candidate</a>() { }
<a name="l00106"></a>00106   
<a name="l00108"></a><a class="code" href="classreranker_1_1_candidate_1_1_comparator.html">00108</a>   <span class="keyword">class </span><a class="code" href="classreranker_1_1_candidate_1_1_comparator.html" title="An inner interface specifying comparison between two Candidate instances.">Comparator</a> : <span class="keyword">public</span> <a class="code" href="classreranker_1_1_factory_constructible.html" title="An interface to make it easier to implement Factory-constructible types by implementing both required...">FactoryConstructible</a> {
<a name="l00109"></a>00109    <span class="keyword">public</span>:
<a name="l00115"></a><a class="code" href="classreranker_1_1_candidate_1_1_comparator.html#ac409d5c25fcc8c66117dfb11a9676e79">00115</a>     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_candidate_1_1_comparator.html#ac409d5c25fcc8c66117dfb11a9676e79" title="An initialization method, guaranteed to be invoked by Factory after initial construction.">Init</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;arg) { }
<a name="l00120"></a>00120     <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classreranker_1_1_candidate_1_1_comparator.html#a4323502821e69d68371baf8a226c8c7f" title="Compares the two specified Candidate instances.">Compare</a>(<span class="keyword">const</span> <a class="code" href="classreranker_1_1_model.html" title="Model is an interface for reranking models.">Model</a> &amp;model,
<a name="l00121"></a>00121                         <span class="keyword">const</span> <a class="code" href="classreranker_1_1_candidate.html" title="A class to represent a candidate in a set of candidates that constitutes a training instance for a re...">Candidate</a> &amp;c1, <span class="keyword">const</span> <a class="code" href="classreranker_1_1_candidate.html" title="A class to represent a candidate in a set of candidates that constitutes a training instance for a re...">Candidate</a> &amp;c2) = 0;
<a name="l00122"></a>00122   };
<a name="l00123"></a>00123 
<a name="l00124"></a>00124   <span class="comment">// accessors</span>
<a name="l00126"></a>00126 <span class="comment"></span>  <span class="comment">// in its set.</span>
<a name="l00127"></a><a class="code" href="classreranker_1_1_candidate.html#a614992f57ceed690dee107b1e4c40696">00127</a>   <span class="keywordtype">int</span> <a class="code" href="classreranker_1_1_candidate.html#a614992f57ceed690dee107b1e4c40696" title="Returns the index of this candidate relative to the other candidates.">index</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> index_; }
<a name="l00130"></a><a class="code" href="classreranker_1_1_candidate.html#ae3b58dc63cb19351a108ff01fb8bc9cf">00130</a>   <span class="keywordtype">int</span> <a class="code" href="classreranker_1_1_candidate.html#ae3b58dc63cb19351a108ff01fb8bc9cf" title="Returns the number of word errors of this candidate relative to a reference string.">num_errors</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> num_errors_; }
<a name="l00133"></a><a class="code" href="classreranker_1_1_candidate.html#a4fea4832eb08476a7212cfcd8cd1212f">00133</a>   <span class="keywordtype">int</span> <a class="code" href="classreranker_1_1_candidate.html#a4fea4832eb08476a7212cfcd8cd1212f" title="Returns the number of correct words of this candidate relative to a reference string.">num_correct</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> num_correct_; }
<a name="l00135"></a><a class="code" href="classreranker_1_1_candidate.html#a024f88c11b795a31cb8f5d1b47150701">00135</a>   <span class="keywordtype">double</span> <a class="code" href="classreranker_1_1_candidate.html#a024f88c11b795a31cb8f5d1b47150701" title="Returns the loss of this candidate.">loss</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> loss_; }
<a name="l00137"></a><a class="code" href="classreranker_1_1_candidate.html#a49d5bb385b20eaaef51a6987a7a230d1">00137</a>   <span class="keywordtype">double</span> <a class="code" href="classreranker_1_1_candidate.html#a49d5bb385b20eaaef51a6987a7a230d1" title="Returns the reranker&rsquo;s score for this candidate.">score</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> score_; }
<a name="l00139"></a><a class="code" href="classreranker_1_1_candidate.html#a008fd660d5f9687efabb3fe839c19b79">00139</a>   <span class="keywordtype">double</span> <a class="code" href="classreranker_1_1_candidate.html#a008fd660d5f9687efabb3fe839c19b79" title="Returns the baseline model score for this candidate.">baseline_score</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> baseline_score_; }
<a name="l00141"></a><a class="code" href="classreranker_1_1_candidate.html#a240be5b1ef5ac9287128cfa4faf373f2">00141</a>   <span class="keywordtype">int</span> <a class="code" href="classreranker_1_1_candidate.html#a240be5b1ef5ac9287128cfa4faf373f2" title="Returns the number of words in this candidate.">num_words</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> num_words_; }
<a name="l00143"></a><a class="code" href="classreranker_1_1_candidate.html#a741433c66a4cc4dfbb1e4b89c9c6e431">00143</a>   <span class="keyword">const</span> <a class="code" href="classreranker_1_1_feature_vector.html">FeatureVector&lt;int,double&gt;</a> &amp;<a class="code" href="classreranker_1_1_candidate.html#a741433c66a4cc4dfbb1e4b89c9c6e431" title="Returns the feature vector for this candidate.">features</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> features_;  }
<a name="l00145"></a><a class="code" href="classreranker_1_1_candidate.html#ab49bd7b1459dcff7c450e5b504204fd5">00145</a>   <span class="keyword">const</span> <a class="code" href="classreranker_1_1_feature_vector.html">FeatureVector&lt;string,double&gt;</a> &amp;<a class="code" href="classreranker_1_1_candidate.html#ab49bd7b1459dcff7c450e5b504204fd5" title="Returns the symbolic feature vector for this candidate.">symbolic_features</a>()<span class="keyword"> const </span>{
<a name="l00146"></a>00146     <span class="keywordflow">return</span> symbolic_features_;
<a name="l00147"></a>00147   }
<a name="l00149"></a><a class="code" href="classreranker_1_1_candidate.html#abb17414a33453509e2b7cfaf8be02baa">00149</a>   <span class="keyword">const</span> <span class="keywordtype">string</span> &amp;<a class="code" href="classreranker_1_1_candidate.html#abb17414a33453509e2b7cfaf8be02baa" title="Returns the raw data (typically the sentence) for this candidate.">raw_data</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> raw_data_; }
<a name="l00153"></a><a class="code" href="classreranker_1_1_candidate.html#a1dae078e72806650bd4af3f7e7a1f451">00153</a>   <span class="keywordtype">bool</span> <a class="code" href="classreranker_1_1_candidate.html#a1dae078e72806650bd4af3f7e7a1f451" title="Returns whether this candidate&rsquo;s symbolic features have been compiled.">compiled</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> compiled_; }
<a name="l00154"></a>00154 
<a name="l00155"></a>00155   <span class="comment">// mutators</span>
<a name="l00157"></a><a class="code" href="classreranker_1_1_candidate.html#a2ae323d5d46d793fa65db5b8fcd0d6d7">00157</a> <span class="comment"></span>  <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_candidate.html#a2ae323d5d46d793fa65db5b8fcd0d6d7" title="Sets the raw data (typically the sentence) for this candidate).">set_raw_data</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;<a class="code" href="classreranker_1_1_candidate.html#abb17414a33453509e2b7cfaf8be02baa" title="Returns the raw data (typically the sentence) for this candidate.">raw_data</a>) { raw_data_ = <a class="code" href="classreranker_1_1_candidate.html#abb17414a33453509e2b7cfaf8be02baa" title="Returns the raw data (typically the sentence) for this candidate.">raw_data</a>; }
<a name="l00158"></a>00158 
<a name="l00162"></a><a class="code" href="classreranker_1_1_candidate.html#a1716a1e38f3b681a60aa5eaedbdc5f0b">00162</a>   <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_candidate.html#a1716a1e38f3b681a60aa5eaedbdc5f0b" title="Sets the score of this candidate.">set_score</a>(<span class="keywordtype">double</span> <a class="code" href="classreranker_1_1_candidate.html#a49d5bb385b20eaaef51a6987a7a230d1" title="Returns the reranker&rsquo;s score for this candidate.">score</a>) { score_ = <a class="code" href="classreranker_1_1_candidate.html#a49d5bb385b20eaaef51a6987a7a230d1" title="Returns the reranker&rsquo;s score for this candidate.">score</a>; }
<a name="l00163"></a>00163 
<a name="l00167"></a><a class="code" href="classreranker_1_1_candidate.html#a839830733c9bd627fd7f82921d740311">00167</a>   <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_candidate.html#a839830733c9bd627fd7f82921d740311" title="Sets the score of this candidate.">set_baseline_score</a>(<span class="keywordtype">double</span> <a class="code" href="classreranker_1_1_candidate.html#a008fd660d5f9687efabb3fe839c19b79" title="Returns the baseline model score for this candidate.">baseline_score</a>) {
<a name="l00168"></a>00168     baseline_score_ = <a class="code" href="classreranker_1_1_candidate.html#a008fd660d5f9687efabb3fe839c19b79" title="Returns the baseline model score for this candidate.">baseline_score</a>;
<a name="l00169"></a>00169   }
<a name="l00170"></a>00170 
<a name="l00174"></a><a class="code" href="classreranker_1_1_candidate.html#afbd3770aa110b9ea80ce2364088a0ffe">00174</a>   <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_candidate.html#afbd3770aa110b9ea80ce2364088a0ffe" title="Sets the loss of this candidate.">set_loss</a>(<span class="keywordtype">double</span> <a class="code" href="classreranker_1_1_candidate.html#a024f88c11b795a31cb8f5d1b47150701" title="Returns the loss of this candidate.">loss</a>) { loss_ = <a class="code" href="classreranker_1_1_candidate.html#a024f88c11b795a31cb8f5d1b47150701" title="Returns the loss of this candidate.">loss</a>; }
<a name="l00175"></a>00175 
<a name="l00195"></a>00195   <span class="keywordtype">bool</span> <a class="code" href="classreranker_1_1_candidate.html#ac6013d797c95fa1b0490b9eedc6053e8" title="Compiles any symbolic features in this candidate.">Compile</a>(<a class="code" href="classreranker_1_1_symbols.html" title="An interface specifying a converter from symbols (strings) to int indices.">Symbols</a> *symbols,
<a name="l00196"></a>00196                <span class="keywordtype">bool</span> clear_features = <span class="keyword">false</span>,
<a name="l00197"></a>00197                <span class="keywordtype">bool</span> clear_symbolic_features = <span class="keyword">true</span>,
<a name="l00198"></a>00198                <span class="keywordtype">bool</span> force = <span class="keyword">false</span>);
<a name="l00199"></a>00199 
<a name="l00215"></a>00215   <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_candidate.html#aeb149e5da4251f1854eadbf50230342c" title="Decompiles any non-symbolic features in this candidate.">Decompile</a>(<a class="code" href="classreranker_1_1_symbols.html" title="An interface specifying a converter from symbols (strings) to int indices.">Symbols</a> *symbols,
<a name="l00216"></a>00216                  <span class="keywordtype">bool</span> clear_symbolic_features = <span class="keyword">false</span>,
<a name="l00217"></a>00217                  <span class="keywordtype">bool</span> clear_features = <span class="keyword">true</span>,
<a name="l00218"></a>00218                  <span class="keywordtype">bool</span> force = <span class="keyword">false</span>);
<a name="l00219"></a>00219 
<a name="l00226"></a><a class="code" href="classreranker_1_1_candidate.html#a87065a82da294d9bd4c64a39de05cf98">00226</a>   <span class="keyword">friend</span> ostream &amp;<a class="code" href="classreranker_1_1_candidate.html#a87065a82da294d9bd4c64a39de05cf98" title="Outputs a human-readable string version of this Candidate instance to the specified ostream...">operator&lt;&lt;</a>(ostream &amp;os, <span class="keyword">const</span> <a class="code" href="classreranker_1_1_candidate.html" title="A class to represent a candidate in a set of candidates that constitutes a training instance for a re...">Candidate</a> &amp;c) {
<a name="l00227"></a>00227     os &lt;&lt; <span class="stringliteral">&quot;{index:&quot;</span> &lt;&lt; c.<a class="code" href="classreranker_1_1_candidate.html#a614992f57ceed690dee107b1e4c40696" title="Returns the index of this candidate relative to the other candidates.">index</a>() &lt;&lt; <span class="stringliteral">&quot;; loss:&quot;</span> &lt;&lt; c.<a class="code" href="classreranker_1_1_candidate.html#a024f88c11b795a31cb8f5d1b47150701" title="Returns the loss of this candidate.">loss</a>()
<a name="l00228"></a>00228        &lt;&lt; <span class="stringliteral">&quot;; score:&quot;</span> &lt;&lt; c.<a class="code" href="classreranker_1_1_candidate.html#a49d5bb385b20eaaef51a6987a7a230d1" title="Returns the reranker&rsquo;s score for this candidate.">score</a>() &lt;&lt; <span class="stringliteral">&quot;; baseline_score:&quot;</span> &lt;&lt; c.<a class="code" href="classreranker_1_1_candidate.html#a008fd660d5f9687efabb3fe839c19b79" title="Returns the baseline model score for this candidate.">baseline_score</a>()
<a name="l00229"></a>00229        &lt;&lt; <span class="stringliteral">&quot;; features:&quot;</span> &lt;&lt; c.<a class="code" href="classreranker_1_1_candidate.html#a741433c66a4cc4dfbb1e4b89c9c6e431" title="Returns the feature vector for this candidate.">features</a>()
<a name="l00230"></a>00230        &lt;&lt; <span class="stringliteral">&quot;; symbolic_features:&quot;</span> &lt;&lt; c.<a class="code" href="classreranker_1_1_candidate.html#ab49bd7b1459dcff7c450e5b504204fd5" title="Returns the symbolic feature vector for this candidate.">symbolic_features</a>()
<a name="l00231"></a>00231        &lt;&lt; <span class="stringliteral">&quot;; raw_data:\&quot;&quot;</span> &lt;&lt; c.<a class="code" href="classreranker_1_1_candidate.html#abb17414a33453509e2b7cfaf8be02baa" title="Returns the raw data (typically the sentence) for this candidate.">raw_data</a>() &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>
<a name="l00232"></a>00232        &lt;&lt; <span class="stringliteral">&quot;; compiled: &quot;</span> &lt;&lt; (c.<a class="code" href="classreranker_1_1_candidate.html#a1dae078e72806650bd4af3f7e7a1f451" title="Returns whether this candidate&rsquo;s symbolic features have been compiled.">compiled</a>() ? <span class="stringliteral">&quot;true&quot;</span> : <span class="stringliteral">&quot;false&quot;</span>)
<a name="l00233"></a>00233        &lt;&lt; <span class="stringliteral">&quot;}&quot;</span>;
<a name="l00234"></a>00234     <span class="keywordflow">return</span> os;
<a name="l00235"></a>00235   }
<a name="l00236"></a>00236 
<a name="l00238"></a><a class="code" href="classreranker_1_1_candidate.html#ac61188c8c9beba920cdc85d7c4f506c8">00238</a>   <span class="keywordtype">string</span> <a class="code" href="classreranker_1_1_candidate.html#ac61188c8c9beba920cdc85d7c4f506c8" title="Returns a the string that would be output by operator&lt;&lt;.">to_string</a>() {
<a name="l00239"></a>00239     std::ostringstream oss;
<a name="l00240"></a>00240     oss &lt;&lt; *<span class="keyword">this</span>;
<a name="l00241"></a>00241     <span class="keywordflow">return</span> oss.str();
<a name="l00242"></a>00242   }
<a name="l00243"></a>00243 
<a name="l00244"></a>00244  <span class="keyword">private</span>:
<a name="l00245"></a>00245   <span class="comment">// Methods for friend class FeatureExtractor.</span>
<a name="l00246"></a>00246   <a class="code" href="classreranker_1_1_feature_vector.html">FeatureVector&lt;int,double&gt;</a> &amp;mutable_features() { <span class="keywordflow">return</span> features_; }
<a name="l00247"></a>00247   FeatureVector&lt;string,double&gt; &amp;mutable_symbolic_features() {
<a name="l00248"></a>00248     <span class="keywordflow">return</span> symbolic_features_;
<a name="l00249"></a>00249   }
<a name="l00250"></a>00250 
<a name="l00251"></a>00251   <span class="comment">// data members</span>
<a name="l00252"></a>00252   <span class="comment">// The index of this candidate in its ordered list of candidates</span>
<a name="l00253"></a>00253   <span class="comment">// (its candidate set).</span>
<a name="l00254"></a>00254   <span class="comment">// TODO(dbikel,kbhall): Is this really necessary?  The CandidateSet</span>
<a name="l00255"></a>00255   <span class="comment">//                      will contain this index.  Maybe this will be</span>
<a name="l00256"></a>00256   <span class="comment">//                      necessary if we want to pass a single</span>
<a name="l00257"></a>00257   <span class="comment">//                      Candidate to a feature function that needs</span>
<a name="l00258"></a>00258   <span class="comment">//                      its &quot;rank&quot; in the CandidateSet.</span>
<a name="l00259"></a>00259   <span class="keywordtype">int</span> index_;
<a name="l00260"></a>00260   <span class="comment">// TODO(dbikel,kbhall): The following three data members seem overly</span>
<a name="l00261"></a>00261   <span class="comment">//                      specific to WER (and therefore to speech</span>
<a name="l00262"></a>00262   <span class="comment">//                      evaluation).  The number of word errors in</span>
<a name="l00263"></a>00263   <span class="comment">//                      this candidate.</span>
<a name="l00264"></a>00264   <span class="keywordtype">int</span> num_errors_;
<a name="l00265"></a>00265   <span class="comment">// The number of correct words in this candidate.a</span>
<a name="l00266"></a>00266   <span class="keywordtype">int</span> num_correct_;
<a name="l00267"></a>00267   <span class="comment">// The loss of this candidate relative to the reference.  For speech, this</span>
<a name="l00268"></a>00268   <span class="comment">// value should be (num_errors_ / num_correct_).</span>
<a name="l00269"></a>00269   <span class="keywordtype">double</span> loss_;
<a name="l00270"></a>00270   <span class="comment">// The score of this candidate according to the reranker.</span>
<a name="l00271"></a>00271   <span class="keywordtype">double</span> score_;
<a name="l00272"></a>00272   <span class="comment">// The baseline model score for this candidate.</span>
<a name="l00273"></a>00273   <span class="keywordtype">double</span> baseline_score_;
<a name="l00274"></a>00274   <span class="comment">// The number of words in this candidate.  (This value might be hard</span>
<a name="l00275"></a>00275   <span class="comment">// or impossible to determine simply from features.)</span>
<a name="l00276"></a>00276   <span class="keywordtype">int</span> num_words_;
<a name="l00277"></a>00277   <span class="comment">// The features for this candidate.</span>
<a name="l00278"></a>00278   FeatureVector&lt;int,double&gt; features_;
<a name="l00279"></a>00279   <span class="comment">// The symbolic features for this candidate.</span>
<a name="l00280"></a>00280   FeatureVector&lt;string,double&gt; symbolic_features_;
<a name="l00281"></a>00281   <span class="comment">// The raw data (string) corresponding to this candidate.</span>
<a name="l00282"></a>00282   <span class="keywordtype">string</span> raw_data_;
<a name="l00283"></a>00283   <span class="comment">// Whether this candidate&#39;s symbolic features have been &quot;compiled&quot;.</span>
<a name="l00284"></a>00284   <span class="keywordtype">bool</span> compiled_;
<a name="l00285"></a>00285 };
<a name="l00286"></a>00286 
<a name="l00287"></a><a class="code" href="candidate_8_h.html#a1f7630ac510baecd375ae40378afb0ce">00287</a> <span class="preprocessor">#define REGISTER_NAMED_CANDIDATE_COMPARATOR(TYPE,NAME) \</span>
<a name="l00288"></a>00288 <span class="preprocessor">  REGISTER_NAMED(TYPE,NAME,Candidate::Comparator)</span>
<a name="l00289"></a>00289 <span class="preprocessor"></span>
<a name="l00290"></a><a class="code" href="candidate_8_h.html#a3a141a31e6cc4e263362be43bd12ee78">00290</a> <span class="preprocessor">#define REGISTER_CANDIDATE_COMPARATOR(TYPE) \</span>
<a name="l00291"></a>00291 <span class="preprocessor">  REGISTER_NAMED_CANDIDATE_COMPARATOR(TYPE,TYPE)</span>
<a name="l00292"></a>00292 <span class="preprocessor"></span>
<a name="l00293"></a>00293 }  <span class="comment">// namespace reranker</span>
<a name="l00294"></a>00294 
<a name="l00295"></a>00295 <span class="preprocessor">#endif</span>
</pre></div></div><!-- contents -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Tue Apr 9 2013 11:56:29 for Reranker Framework (ReFr) by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>
